package beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name= "Salones")
public class Salon implements Serializable
{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5739092664089790729L;

	@Id
	private int idSalon;
	
	@OneToMany (cascade=CascadeType.ALL, fetch=FetchType.EAGER)
    @JoinColumn(name="nroSector")
    private List<Sector> sectores;
    
	
    public List<Sector> getSectores() {
		return sectores;
	}

	public void setSectores(List<Sector> sectores) {
		this.sectores = sectores;
	}
	

	public Salon() {
		sectores = new ArrayList<Sector>();
	}

	public void asignarMesaASector( Sector s, Mesa m)
    {
    
    }

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + idSalon;
		result = prime * result
				+ ((sectores == null) ? 0 : sectores.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Salon other = (Salon) obj;
		if (idSalon != other.idSalon)
			return false;
		if (sectores == null) {
			if (other.sectores != null)
				return false;
		} else if (!sectores.equals(other.sectores))
			return false;
		return true;
	}
}
